import http from '@/utils/service';

const API = {
  getRestaurantList: '/restaurant/getRestaurantList',
  getSeatById: 'restaurant/getSeat',
  createSeat: 'restaurant/createSeat',
  getRestaurantMonthSales: 'restaurant/getRestaurantMonthSales',
  getRestaurantSales: 'restaurant/getRestaurantSales?restaurantId=',
  createRestaurant: 'restaurant/createRestaurant',
  updateStatus: 'restaurant/updateStatus?restaurantId=',
  getRestaurantsList: '/restaurant/getRestaurantsList',
  getAfterSales: '/restaurant/getAfterSales?dishId=',
  recommendRestaurants: '/restaurant/recommendRestaurants?userId=',
};

export interface DataType {
  id: number;
  name: string;
  score: number;
  state: number;
  image: string;
}

export interface GetDishPage {
  name: string;
  current: number;
  size: number;
  masterId: number;
  sortField: string;
  sortOrder: string;
}
export interface QueryMonthSales {
  restaurantId: number;
  date: string;
}
export interface MonthSales {
  total: number;
  dishList: {
    name: string;
    num: number;
  }[];
}

export interface CreateRestaurant {
  restaurantName: string;
  restaurantAddress: string;
  phone: string;
}

export interface AfterSales {
  sales: {
    date: string;
    futureSales: number;
  }[];
}
export interface RecommendRestaurants {
  recommendRestaurant: {
    id: number;
    name: string;
    score: number;
    image: string;
  }[];
}

export const getRestaurantListAPI = (data: GetDishPage) =>
  http.post(API.getRestaurantList, { data });

export const getRestaurantListsAPI = (data: GetDishPage) =>
  http.post(API.getRestaurantsList, { data });

export const getRestaurantMonthSales = (data: QueryMonthSales) =>
  http.post(API.getRestaurantMonthSales, { data });

export const getRestaurantSalesAPI = (restaurantId: number) =>
  http.get(API.getRestaurantSales + restaurantId);

export const createRestaurantAPI = (data: CreateRestaurant) =>
  http.post(API.createRestaurant, { data });
export const updateStatusAPI = (id: number) => http.get(API.updateStatus + id);

export const getAfterSalesAPI = (id: number) =>
  http.get(API.getAfterSales + id);

export const recommendRestaurantsAPI = (id: number) =>
  http.get(API.recommendRestaurants + id);
